/*
 * @Descripttion: 门店升级
 * @version:
 * @Author: lehaixia
 * @Date: 2023-05-03 09:52:12
 * @LastEditors: lehaixia
 * @LastEditTime: 2023-05-25 14:24:21
 */
import request from '@/plugins/request'
import { IResponseData } from '@/types/request-base'
import { json2FormData } from '@/utils'

/**
 * 门店升级查询
 * @param {object} data 参数
 */
export function getList({ page, rows, sort, order, filtersRaw, sortersRaw, paramsRaw }: any) {
  const params = {
    page,
    rows,
    sort: '',
    order: order || 'desc',
    pageFlag: true,
    onlyCountFlag: false,
    filtersRaw: JSON.stringify(filtersRaw),
    sortersRaw: JSON.stringify(sortersRaw),
    paramsRaw: JSON.stringify(paramsRaw)
  }
  const data = json2FormData(params)
  return request<IResponseData>({
    url: '/app/v1/ctmMarketTask/page',
    method: 'post',
    data
  })
}

/**
 *  编辑
 * @param data any
 * @returns
 */
export function save(data: any) {
  return request<IResponseData>({
    url: '/app/v1/ctmMarketTask',
    method: 'put',
    data
  })
}

/**
 * 提报跟进信息
 * @param data
 * @returns
 */
export function submit(data: any) {
  return request<IResponseData>({
    url: '/app/v1/ctmMarketTask/submit',
    method: 'put',
    data
  })
}

/**
 * 详情 根据ID查询
 * @param {string} marketId
 */
export function detail(marketId: string) {
  return request<IResponseData>({
    method: 'get',
    url: `/app/v1/ctmMarketTask/${marketId}`,
    loading: true
  })
}

/**
 * 跟进记录 列表
 * @param {string} marketId
 */
export function marketDetail(marketId: string) {
  return request<IResponseData>({
    method: 'get',
    url: `/app/v1/ctmMarketTask/getListAppByMarketId/${marketId}`
  })
}

/**
 * 跟进记录 详情
 * @param {string} marketId
 */
export function marketDataDetail(marketId: string) {
  return request<IResponseData>({
    method: 'get',
    url: `/app/v1/ctmMarketTask/getDataAppByMarketId/${marketId}`,
    loading: true
  })
}
